package tbdp.tool.format.csv;

import java.util.ArrayList;
import java.util.List;

import tbdp.tool.common.ColumnDesc;
import tbdp.tool.common.Record;
import tbdp.tool.format.Formatter;

/**
 * @author xbkaishui
 * @version $Id: CsvFormatter.java, v 0.1 2017-06-22 下午10:40 xbkaishui Exp $$
 */
public class CsvFormatter extends Formatter {
    @Override
    public List<Object> format(ColumnDesc[] header, Record record) {
        List<Object> result = new ArrayList(header.length);
        for (ColumnDesc col : header) {
            Object val = record.get(col.getColumn());
            if (val == null) {
                val = "";
            }
            result.add(val);
        }
        return result;
    }

    @Override
    public String getType() {
        return "csv";
    }
}
